package com.h52mm.curator;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class DelCuratorSample {

    public static void main(String[] args) throws Exception {
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework client = CuratorFrameworkFactory.builder()
                .connectString("127.0.0.1:2182") //server地址
                .sessionTimeoutMs(50000) // 会话超时时间
                .connectionTimeoutMs(30000) // 连接超时时间
                .retryPolicy(retryPolicy) // 重试策略
                .namespace("curator") // 独⽴命名空间/base
                .build(); //
        client.start();
        System.out.println("Zookeeper session established");

        String path="/test_del";
        client.delete().deletingChildrenIfNeeded().withVersion(-1).forPath(path);
        System.out.println("success create znode"+path);

    }

}
